<template>
  <el-dropdown trigger="click">
    <ElButton link>更多<icon icon="ep:arrow-right" /></ElButton>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item v-for="(action, i) in actions" :key="i" @click.stop="doAction(action, unit, row)">
          <icon :icon="getIcon(action)" :color="action.color" :size="action.size" :hover-color="action.hoverColor" />
          {{ getLabel(action) }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
<script lang="ts" setup>
  import { ElDropdown, ElDropdownMenu, ElDropdownItem, ElButton } from 'element-plus'
  import { Icon } from '@/components/Icon'
  import { Action, Unit } from '@/seed-application/types';
  import { doAction } from '@/seed-application/actions';
  import { getIcon, getLabel } from '@/seed-application/utils/ActionUtil';
  import { inject } from 'vue';
  import { unitKey } from '@/seed-application';
  
  defineProps<{actions: Action[], row: any}>()
  const unit = inject<Unit>(unitKey, void 0)
</script>